using QFramework.Framework;
using UnityEditor;
using UnityEngine;

namespace QFramework.Example._5.AudioManager
{
    public class AudioExample : MonoBehaviourSimplify
    {
        private void Start()
        {
            Framework.Manager.AudioManager.Instance.PlaySound("Hit");

            Delay(0.05f, () => { Framework.Manager.AudioManager.Instance.PlaySound("Hit"); });

            Delay(1.0f, () => { Framework.Manager.AudioManager.Instance.PlayMusic("Start", true); });

            Delay(3.0f, () => { Framework.Manager.AudioManager.Instance.PauseMusic(); });

            Delay(5.0f, () => { Framework.Manager.AudioManager.Instance.ResumeMusic(); });

            Delay(7.0f, () => { Framework.Manager.AudioManager.Instance.StopMusic(); });

            Delay(9.0f, () => { Framework.Manager.AudioManager.Instance.PlayMusic("Start", true); });

            Delay(11.0f, () => { Framework.Manager.AudioManager.Instance.MusicOff(); });

            Delay(13.0f, () => { Framework.Manager.AudioManager.Instance.MusicOn(); });
        }

#if UNITY_EDITOR
        [MenuItem("QFramework/Example/5.AudioManager", false, 5)]
        private static void MenuClicked()
        {
            EditorApplication.isPlaying = true;
            new GameObject("AudioExample").AddComponent<AudioExample>();
        }
#endif

        protected override void OnBeforeDestroy()
        {
        }
    }
}